<!-- 发布房源 -->
<template>
    <ConfirmBox
        title=""
        :confirmText="confirmText"
        :confirmClass="confirmClass"
        :hideConfirm="false"
        @confirm="releaseSource"
        :full="true"
    >
        <view class="h-56 w-full">
            <image :src="bg_mai_fang" mode="scaleToFill" class="img" />
        </view>
        <view class="relative z-10 px-4 pb-4">
            <view class="bg-white p-4 rounded-lg pb-1">
                <view class="text-xl font-bold mb-4">填写房屋信息</view>
                <uni-forms
                    ref="baseForm"
                    :modelValue="baseFormData"
                    label-width="100px"
                >
                    <uni-forms-item label="房产证号" required name="name">
                        <uni-easyinput
                            v-model="baseFormData.name"
                            placeholder="请输入房产证号"
                        />
                    </uni-forms-item>
                    <uni-forms-item label="意向总价" required name="age">
                        <uni-easyinput
                            v-model="baseFormData.age"
                            placeholder="请输入意向总价"
                        />
                    </uni-forms-item>
                    <uni-forms-item label="委托经纪人" required name="sex">
                        <uni-data-checkbox
                            v-model="baseFormData.sex"
                            :localdata="leaders"
                        />
                    </uni-forms-item>
                    <uni-forms-item
                        label="经纪人"
                        required
                        v-if="baseFormData.sex == 0"
                    >
                        <view
                            class="text-gray-400 text-right h-full flex items-center justify-end cursor-pointer"
                            @click="selectBroker"
                        >
                            请选择经纪人<uni-icons
                                type="right"
                                color="#a3af9c"
                            ></uni-icons>
                        </view>
                    </uni-forms-item>
                    <uni-forms-item label="联系方式">
                        <uni-easyinput
                            v-model="baseFormData.introduction"
                            placeholder="请输入联系方式"
                        />
                    </uni-forms-item>
                    <view class="column-layer">
                        <uni-forms-item label="房屋现场照片">
                            <view class="example-body">
                                <uni-file-picker
                                    limit="3"
                                    v-model="baseFormData.picList"
                                ></uni-file-picker>
                            </view>
                        </uni-forms-item>
                    </view>
                    <view class="column-layer">
                        <uni-forms-item label="产证照片">
                            <uni-file-picker
                                limit="3"
                                v-model="baseFormData.picList"
                            ></uni-file-picker>
                        </uni-forms-item>
                    </view>
                </uni-forms>
            </view>
            <view class="px-4 flex items-center mt-6">
                <view class="w-full h-[1rpx] bg-gray-400"></view>
                <view class="flex-none px-2 text-gray-400">房源发布流程</view>
                <view class="w-full h-[1rpx] bg-gray-400"></view>
            </view>
            <view class="px-4">
                <SellStep :steps="-1"></SellStep>
            </view>
        </view>
    </ConfirmBox>
</template>
<script setup lang="ts">
import ConfirmBox from "@/components/ConfirmBox/index.vue";
import SellStep from "@/components/SellStep/index.vue";
import bg_mai_fang from "@/static/bg_maifang.png";
import { $global } from "@/store";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { ref } from "vue";
const releaseSource = () => {
    $global.showToast({
        title: "发布成功",
    });
    $global.movePath("", true);
};

onShow(() => {
    uni.$once("update", (data) => {
        console.log(data);
    });
});

const baseFormData = ref({
    name: "",
    age: "",
    introduction: "",
    sex: 0,
    hobby: [5],
    datetimesingle: 1627529992399,
    picList: [],
});

const leaders = ref([
    {
        text: "指定经纪人",
        value: 0,
    },
    {
        text: "不指定经纪人",
        value: 1,
    },
]);

const selectBroker = () => {
    $global.movePath("/pages/mine/children/BrokerSelect/index?type=select");
};

const confirmText = ref("");
const confirmClass = ref("");
onLoad((e) => {
    if (e && e.type == "publish") {
        confirmText.value = "提交信息";
        confirmClass.value = "primary";
    } else {
        confirmText.value = "不卖了";
        confirmClass.value = "info";
    }
});
</script>
<style scoped lang="scss">
.img {
    width: 100%;
    height: 80vw;
}
:deep(.is-input-border) {
    border: 0rpx !important;
}
.uni-easyinput__placeholder-class {
    font-size: 24rpx;
}
</style>
